package com.xdf.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xudengfeng
 * @date 2020/12/3 20:16
 */

@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
@Data
public class DataSourceConfiguration {
    String driverClassName;
    String url;
    String username;
    String password;

    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }

}
